package controler;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import java.util.Observable;

import javax.swing.JOptionPane;

import template.AbstractListener;
import template.AbstractSystem;

import model.BooleanModel;
import model.Delivery;

public class StopListener extends AbstractListener implements ActionListener {

	private static final long serialVersionUID = 1L;

	public StopListener(Observable obs1, Observable obs2, Observable obs3) {
		addModel(obs1);
		addModel(obs2);
		addModel(obs3);
	}

	public void actionPerformed(ActionEvent evt) {
		int yes = JOptionPane.showConfirmDialog(AbstractSystem.CURRENTSYSTEM,
				"Are you sure you want to stop the command?", "Confirmation",
				JOptionPane.YES_NO_OPTION);
		if (yes == 0) {

			Delivery delivery = (Delivery) getModel(0);
			BooleanModel boolModelPanel = (BooleanModel) getModel(1);
			BooleanModel boolModelButton = (BooleanModel) getModel(2);

			delivery.removeAllDeliveryElements();
			boolModelPanel.setValue(false);
			boolModelButton.setValue(false);
		}
	}
}
